import { request } from '@/utils'

export function getFriendList(friendDTO) {
  return request({
    url: '/admin/friends',
    method: 'POST',
    data: JSON.stringify(friendDTO),
    headers: {
      'Content-type': 'application/json;charset=utf-8',
    },
  })
}

export function getFriendById(id) {
  return request({
    url: '/admin/friend',
    method: 'GET',
    params: {
      id,
    },
  })
}

export function addFriend(friendForm) {
  return request({
    url: '/admin/friend',
    method: 'POST',
    data: JSON.stringify(friendForm),
    headers: {
      'Content-type': 'application/json;charset=utf-8',
    },
  })
}

export function updateFriend(friendForm) {
  return request({
    url: '/admin/updateFriend',
    method: 'POST',
    data: JSON.stringify(friendForm),
    headers: {
      'Content-type': 'application/json;charset=utf-8',
    },
  })
}

export function removeFriend(id) {
  return request({
    url: '/admin/removeFriend',
    method: 'POST',
    params: {
      id,
    },
  })
}

export function publishFriend(id, isPublished) {
  return request({
    url: '/admin/publishFriend',
    method: 'POST',
    params: {
      id,
      isPublished,
    },
  })
}

export function getFriendByName(nickName) {
  return request({
    url: '/admin/getFriendByName',
    method: 'GET',
    params: {
      nickName,
    },
  })
}
